/*
 * bucket.h
 *
 *  Created on: 27 Apr 2010
 *      Author: osky
 */

#ifndef BUCKET_H_
#define BUCKET_H_

#include <stdio.h>
#include "c_registro.h"
#include "c_bloque.h"
#include "constantes.h"

class c_bucket

    {
    // ********************************** //
    private:

        unsigned int nro_bucket;
        unsigned int reg_por_bucket; /* Efectivamente cargados */
        unsigned int bits_en_comun; /* Catidad de bits en comun que tienen los elementos del bucket */
        unsigned int espacio_libre;

        c_registro registros[MAX_REGISTROS_POR_BUCKET] ;

        c_bloque mem_buffer;

    // ********************************** //
    public:

        c_bucket (int n_bucket);
        unsigned int ocupado ();
        void set_bits_en_comun (unsigned int bits);
        unsigned int get_bits_en_comun (void);
        void get ( unsigned int &g_nro_bucket, unsigned int &g_reg_por_bucket);
        int dump_registro(unsigned int nro_registro);
        int buscar_clave ( unsigned int clave);
        int insertar_reg ( c_registro* reg);
        int dividir ( c_bucket* bucket_0, c_bucket* bucket_1);
        int eliminar_dato ( unsigned int clave);

        int save();
        int load ();
        
        void dump (FILE* handler);

};
#endif /* BUCKET_H_ */
